{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!byzerllm deploy --pretrained_model_type saas/openai \\\n",
    "--cpus_per_worker 0.001 \\\n",
    "--gpus_per_worker 0 \\\n",
    "--num_workers 1 \\\n",
    "--infer_params saas.api_key=${MODEL_OPENAI_TOKEN} saas.model=tts-1 \\\n",
    "--model openai_tts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import byzerllm\n",
    "import base64\n",
    "import json\n",
    "\n",
    "llm = byzerllm.ByzerLLM.from_default_model(\"openai_tts\")\n",
    "\n",
    "\n",
    "t = llm.chat_oai(conversations=[{\n",
    "    \"role\":\"user\",\n",
    "    \"content\": json.dumps({\n",
    "        \"input\":\"hello, open_tts\",\n",
    "        \"voice\": \"alloy\",\n",
    "        \"response_format\": \"mp3\"\n",
    "    },ensure_ascii=False)\n",
    "}])\n",
    "\n",
    "with open(\"voice.mp3\",\"wb\") as f:\n",
    "    f.write(base64.b64decode(t[0].output))"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
